<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/


/** Component to create simple menu
 *
 * Parameters:
 *  'aMenuItems' - menu items array ('pagename'=>'title', or 'pagename' => array(...) )
 *  'sTemplate' - template name ('Menu', 'TabbedMenu')
 *  'aParams'   - additional params to create url for menu items
 *
 *
 */
class PhpFox_Mod_Menu_ComponentMainMenu extends BaseComponent
{
    function process()
    {
    	static $_PHPFOX;

    	// $this->oTpl->caching = 1;

    	$sLocation = $this->getParam('location');
    	$sTemplate = $this->getParam('template');

    	if ( !$sLocation )
    	{
    		return '';
    	}

    	if ( !$sTemplate )
    	{
    		return '';
    	}

    	//if( !$this->oTpl->is_cached(''. $sTemplate .'.html') )
    	//{
	    	switch($sLocation)
	    	{
	    		case 'main':
	    		$sType = "0";
	    		break;
	    		case 'header':
	    		$sType = "1";
	    		break;
	    		case 'bottom':
	    		$sType = "2";
	    		break;
	    	}

	    	if ( !isset($sType) )
	    	{
	    		trigger_error('Menu::MainMenu cant find the variable $sType', E_USER_ERROR);
	    	}

			if ( !isset($_PHPFOX['menu_'. $sType .'']) )
			{
				$oSrvMenu = &$this->_oModule->getService('Menu');

	    		$_PHPFOX = $oSrvMenu->_cacheMenu();
			}

			if ( !isset($_PHPFOX['menu_'. $sType .'']) )
			{
				return '';
			}

			$this->oTpl->assign(array
			(
				'aMenuItems' => $_PHPFOX['menu_'. $sType .''],
				'isMember' => App::getUser('id'),
			));
		//}

     	$srcHtml = $this->oTpl->fetch(''. $sTemplate .'.html');
        return $srcHtml;
    }
}
?>
